%let syear=2014;

* [] brackets indicate redacted internal census variable name or directory that can't be disclosed. ;

*storing  SAS libraries;
libname hannah  '/projects/users/########';
libname ben   '/projects/users/########';

* append CA wind capacities to all other states;
proc append base = hannah.all_styr_100p 
  data = hannah.all_cayr_100p;
run;

* MERGE TO ehf_icf_states;
proc sql;
  create table hannah.ehf_icf_states_plants as
  select 
    a.*,
    b.plantcap100, b.turbnum100, b.plantcap80, b.turbnum80,
    b.plantcap60, b.turbnum60, b.plantcap40, b.turbnum40,
    b.plantcap20, b.turbnum20
  from hannah.ehf_icf_states as a
    left join hannah.all_styr_100p as b
    on a.pik = b.pik and a.year = b.[year] 
  order by a.pik, a.year;
quit;

data hannah.ehf_icf_states_plants;
  set hannah.ehf_icf_states_plants;
  IF CMISS(plantcap100) THEN plantcap100 = 0;
  IF CMISS(turbnum100) THEN turbnum100 = 0;
  IF CMISS(plantcap80) THEN plantcap80 = 0;
  IF CMISS(turbnum80) THEN turbnum80 = 0;
  IF CMISS(plantcap60) THEN plantcap60 = 0;
  IF CMISS(turbnum60) THEN turbnum60 = 0;
  IF CMISS(plantcap40) THEN plantcap40 = 0;
  IF CMISS(turbnum40) THEN turbnum40 = 0;
  IF CMISS(plantcap20) THEN plantcap20 = 0;
  IF CMISS(turbnum20) THEN turbnum20 = 0;
run; 
